<template>
  <view v-if="shenheStatus == 0" class="d_box">
    <view class="card_box">
      <view class="card_top">
        <image
          :src="pic"
          style="
            height: 60rpx;
            width: 60rpx;
            border-radius: 50rpx;
            transform: translateY(18rpx);
            display: inline-block;
          "
        ></image>
        <text
          style="
            margin-left: 30rpx;
            font-size: 32rpx;
            color: #666666;
            font-weight: 600;
          "
          >{{ name }}</text
        >
      </view>
      <view class="code_box">
        <view style="font-size: 32rpx">
          {{ $t('order.clerk') }}
        </view>
        <view style="margin: 30rpx auto">
          <image
            :src="url"
            mode="widthFix"
            style="width: 80%; background-color: #cccccc; margin: 0 auto"
          ></image>
        </view>
        <view style="color: #999999; font-size: 28rpx">
          {{ $t('writeOff.useCode') }}
        </view>
      </view>
    </view>
  </view>
  <Shenhe v-else-if="shenheStatus == 1"></Shenhe>
</template>

<script>
import Shenhe from '@/components/shenhe/shenhe';
export default {
  components: { Shenhe },
  data() {
    return {
      url: '',
      name: '',
      pic: '',
    };
  },
  onLoad(opt) {
    uni.setNavigationBarTitle({
      title: this.$t('title.writeOffCode'),
    });
    this.getCode(opt.id);
    this.name = opt.name;
    this.pic = opt.pic;
  },
  methods: {
    async getCode(id) {
      try {
        const res = await this.$allrequest.coupon.userCardQrcode({
          user_card_id: id,
        });
        if (res.code == 0) {
          this.url = res.data.url;
        } else {
          this.$utils.toast(res.msg);
        }
      } catch (e) {
        //TODO handle the exception
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.code_box {
  text-align: center;
  padding: 40rpx 0;
}
.card_top {
  padding-left: 40rpx;
  background-color: rgb(250, 250, 250);
  height: 100rpx;
  line-height: 100rpx;
  position: relative;
  &::before {
    content: '';
    width: 15rpx;
    height: 15rpx;
    position: absolute;
    background-color: rgb(66, 68, 71);
    left: 0;
    top: 100rpx;
    transform: rotate(45deg) translateX(-60%);
  }
  &::after {
    content: '';
    width: 15rpx;
    height: 15rpx;
    position: absolute;
    background-color: rgb(66, 68, 71);
    right: 0;
    top: 85rpx;
    transform: rotate(45deg) translateX(60%);
  }
}
.card_box {
  width: 100%;
  background-color: #fff;
  border-radius: 10rpx;
  overflow: hidden;
}
.d_box {
  height: 100vh;
  background-color: rgb(66, 68, 71);
  padding: 30rpx;
}
</style>
